Skip to content

JIT: Merge all RETURN/THROW blocks#128515

Open
BoyBaykiller wants to merge 1 commit into
dotnet:mainfrom
BoyBaykiller:deduplicate-all-return-throw-blocks
Open

JIT: Merge all RETURN/THROW blocks#128515
BoyBaykiller wants to merge 1 commit into
dotnet:mainfrom
BoyBaykiller:deduplicate-all-return-throw-blocks

Conversation

@BoyBaykiller
Copy link
Copy Markdown
Contributor

Fix #128514

tailMergePreds(nullptr) was called once, but my understanding is it needs to be called repeatedly as it only processes one set at at time.

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 23, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 23, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@BoyBaykiller
Copy link
Copy Markdown
Contributor Author

@AndyAyersMS PTAL.

Comment thread src/coreclr/jit/fgopt.cpp
// Avoid splitting a return away from a possible tail call
//
if (!block->hasSingleStmt())
if (block->isEmpty())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check was here before, but I dont think we actually need it. Because we only accept RETURN or THROW blocks and these should never be empty?

Copy link
Copy Markdown
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do this without repeatedly searching all blocks for returns and throws?

Comment thread src/coreclr/jit/fgopt.cpp
do
{
predInfo.Reset();
for (BasicBlock* const block : Blocks())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set of eligible return and throw blocks never changes, so do we need to repeatedly walk the entire block list here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also think we don't need to, however when I tried to hoist that it caused asserts.
I didn't look further into it because the same approach is already done in iterateTailMerge() and there are also multiple comments arround this code about improving algorithm efficiency.
So I'd prefer properly understanding the entire code and improving efficiency in a separate PR, in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: Missing deduplication of RETURN block causes switch recognition to miss JTRUEs

2 participants